package com.jingxi.rest.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.jingxi.common.pojo.JingXiResult;
import com.jingxi.model.TbContent;
import com.jingxi.model.TbItem;
import com.jingxi.rest.service.ContentService;

@Controller
@RequestMapping("/content")
public class ContentController {

	@Autowired
	private ContentService contentService;

	@RequestMapping("/list/{contentCategoryId}")
	@ResponseBody
	public JingXiResult getContentList(@PathVariable Long contentCategoryId) {

		try {
			List<TbContent> list = contentService.getContentList(contentCategoryId);
			//System.out.println("listssss" + list);
			return JingXiResult.ok(list);
		} catch (Exception e) {
			e.printStackTrace();
			return JingXiResult.build(500, e.getMessage());
		}
	}
	

	@RequestMapping("/new")
	@ResponseBody
	public JingXiResult showNewList(){
		try {
			List<TbItem> list = contentService.showNewList();
			return JingXiResult.ok(list);
		} catch (Exception e) {
			e.printStackTrace();
			return JingXiResult.build(500, e.getMessage());
		}
	}
	
	@RequestMapping("/hot")
	@ResponseBody
	public JingXiResult showHotList(){
		try {
			List<TbItem> list = contentService.showHotList();
			System.out.println("listssss" + list);
			return JingXiResult.ok(list);
		} catch (Exception e) {
			e.printStackTrace();
			return JingXiResult.build(500, e.getMessage());
		}
	}
	
	@RequestMapping("/clothes")
	@ResponseBody
	public JingXiResult showClothesList(){
		try {
			List<TbItem> list = contentService.showClothesList();
			return JingXiResult.ok(list);
		} catch (Exception e) {
			e.printStackTrace();
			return JingXiResult.build(500, e.getMessage());
		}
	}
	
	@RequestMapping("/gift")
	@ResponseBody
	public JingXiResult showGiftList(){
		try {
			List<TbItem> list = contentService.showGiftList();
			return JingXiResult.ok(list);
		} catch (Exception e) {
			e.printStackTrace();
			return JingXiResult.build(500, e.getMessage());
		}
	}
	
	@RequestMapping("/flower")
	@ResponseBody
	public JingXiResult showFlowerList(){
		try {
			List<TbItem> list = contentService.showFlowerList();
			return JingXiResult.ok(list);
		} catch (Exception e) {
			e.printStackTrace();
			return JingXiResult.build(500, e.getMessage());
		}
	}
	
}
